<template>
  <div class="bg">
    <div class="content">
      <div class="l-left">
        <div class="brand-info">
          <div class="brand-name">湘软科技</div>
          <div class="brand-slogan">XiangRuanKeJi</div>
        </div>
        <!-- 这里可以放 logo、介绍语、插画 -->
        <div class="bg-overlay"></div>
        <!-- <div class="desc">
          <div class="title">
            iMES<span
              style="
                font-size: 13px;
                background: #46c706;
                border-radius: 24px;
                padding: 4px 9px;
                border: 1px solid;
                margin-left: 5px;
              "
              >工厂管家</span
            >
          </div>
          <p>最值得信赖的新一代工厂管家</p>
          <p>计划管理，工单，订单，生产管理，库存管理</p>
          <p>工序，报工，基础数据，大屏，报表</p>
          <p>手机APP移动端管理，无需电脑</p>
          <p>演示账号：admin 密码:123456</p>
          <p>Java版:https://java.625sc.com:8443/imes</p>
          <p>Java版本演示账号：admin 密码:admin</p>
          <div style="margin-top: 30px" class="link">
            <a href="https://www.625sc.com/imes/313.html" target="_blank">
              <span>亮点说明</span></a
            >
            <a href="https://www.625sc.com/imes/" target="_blank">
              <span>项目介绍</span></a
            >
            <a href="https://www.bilibili.com/video/BV1KY4y1d7EC" target="_blank">
              <span>视频介绍</span></a
            >
            <a href="https://www.bilibili.com/video/BV11M4y197Hy" target="_blank">
              <span>补充介绍</span></a
            >
            <a href="https://java.625sc.com:8443/imes" target="_blank">
              <span>Java版本</span></a
            >
          </div>
        </div> -->
      </div>
      <div class="login">
        <div class="login-contianer">
          <div class="login-form">
            <h2 class="login-title">账号登录</h2>
            <!-- <div class="v-tag">商业版</div> -->
            <div class="form-user" @keypress="loginPress">
              <!-- <div class="item">
                <div class="f-text">
                  <label> 用户名： </label>
                </div>
                <div class="f-input">
                  <input
                    type="text"
                    v-focus
                    v-model="userInfo.userName"
                    placeholder="输入用户"
                  />
                </div>
              </div>
              <div class="item">
                <div class="f-text">
                  <label> 密&nbsp;&nbsp;&nbsp;码： </label>
                </div>
                <div class="f-input">
                  <input
                    type="password"
                    v-focus
                    v-model="userInfo.password"
                    placeholder="输入密码"
                  />
                </div>
              </div> -->

              <div class="form-user" @keypress="loginPress">
                <!-- 用户名 -->
                <div class="item">
                  <div class="icon"><i class="el-icon-user"></i></div>
                  <input type="text" v-focus v-model="userInfo.UserName" placeholder="请输入用户名" />
                </div>

                <!-- 密码 -->
                <div class="item">
                  <div class="icon"><i class="el-icon-lock"></i></div>
                  <input type="password" v-focus v-model="userInfo.PassWord" placeholder="请输入密码" />
                </div>
              </div>

              <!-- <div class="item">
                <div class="f-text">
                  <label> 验证码： </label>
                </div>
                <div class="f-input">
                  <input
                    v-focus
                    type="text"
                    v-model="userInfo.verificationCode"
                    placeholder="输入验证码"
                  />
                </div>
                <div class="code" @click="getVierificationCode">
                  <img v-show="codeImgSrc != ''" :src="codeImgSrc" />
                </div>
              </div> -->
            </div>
            <div class="loging-btn">
              <el-button size="large" :loading="loading" type="primary" @click="login" long>
                <span v-if="!loading" class="btn-text">登录</span>
                <span v-else>正在登录...</span>
              </el-button>
            </div>
            <div class="app-link">
              <a href="https://wechat.625sc.com:8891/iMES.exe" style="text-decoration: none">桌面客户端</a>
              <a>
                <i class="el-icon-chat-dot-round"></i> 小程序
                <img src="https://wechat.625sc.com:8891/WXApp.jpg" /></a>
              <a>
                <i class="el-icon-mobile-phone"></i>
                Android
                <img src="https://wechat.625sc.com:8891/Android.png" /></a>
              <a>
                <i class="el-icon-document"></i>
                H5
                <img src="https://wechat.625sc.com:8891/H5.png" /></a>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="l-bg"></div>
    <div class="r-bg"></div>

    <!-- <div class="login-footer">
      <a
        style="text-decoration: none"
        href="https://beian.miit.gov.cn/"
        target="_blank"
        >Copyright © 2022 邢台硒恩园信息科技有限公司 版权所有 冀ICP备2021023799号-1</a
      >
      <a>作者QQ/微信：514224717</a>
    </div> -->
  </div>
</template>
<script>
import {
  defineComponent,
  ref,
  reactive,
  toRefs,
  getCurrentInstance,
} from "vue";
import { useRouter, useRoute } from "vue-router";
import store from "../store/index";
import http from "@/../src/api/http.js";
export default defineComponent({
  setup(props, context) {
    const loading = ref(false);
    const codeImgSrc = ref("");
    const userInfo = reactive({
      UserName: "",
      PassWord: "",
      // verificationCode: "",
      UUID: undefined,
    });

    // const getVierificationCode = () => {
    //   http.get("/api/User/getVierificationCode").then((x) => {
    //     codeImgSrc.value = "data:image/png;base64," + x.img;
    //     userInfo.UUID = x.uuid;
    //   });
    // };
    // getVierificationCode();

    let appContext = getCurrentInstance().appContext;
    let $message = appContext.config.globalProperties.$message;
    let router = useRouter();


    const login = () => {
      if (!userInfo.UserName) return $message.error("请输入用户名");
      if (!userInfo.PassWord) return $message.error("请输入密码");
      // if (!userInfo.verificationCode) {
      //   return $message.error("请输入验证码");
      // }
      loading.value = true;
      //http.post("/api/user/login", userInfo, "正在登录....").then((result) => {
      console.log("111")
      http.post("/api/user2/login", userInfo, "正在登录....").then((result) => {
        if (!result.status) {
          console.log(JSON.stringify(result, null, 2));
          loading.value = false;
          // getVierificationCode();
          return $message.error(result.message);
        }
        $message.success("登录成功,正在跳转!");
        console.log("打印语句" + JSON.stringify(result.data, null, 2));
        store.commit("setUserInfo", result.data);
        router.push({ path: "/" });
        console.log("跳转已执行！")
      });

      // $message.success("登录成功,正在跳转!");
      // router.push({ path: "/" });

    };
    const loginPress = (e) => {
      if (e.keyCode == 13) {
        login();
      }
    };
    const openUrl = (url) => {
      window.open(url, "_blank");
    };
    return {
      loading,
      codeImgSrc,
      // getVierificationCode,
      login,
      userInfo,
      loginPress,
      openUrl,
    };
  },
  directives: {
    focus: {
      inserted: function (el) {
        el.focus();
      },
    },
  },
});
</script>

<style lang="less" scoped>
// .bg {
//   display: flex;
//   overflow: hidden;
//   position: relative;
//   height: 100%;
//   width: 100%;
//   background-image: linear-gradient(135deg, #24aded 10%, #40b3e8);//中间背景
// }
.bg {
  position: relative;
  width: 100%;
  height: 100vh;
  background: url(~@/assets/imgs/bg_logo.png) no-repeat center center;
  background-size: cover;
  overflow: hidden;

  &::before {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4); // 半透明黑色遮罩
    z-index: 1;
  }
}

// /*  遮罩层 */
// .bg-overlay {
//   position: absolute;
//   top: 0;
//   left: 0;
//   width: 100%;
//   height: 100%;
//   z-index: 1; //  登录卡片 z-index: 10，所以这个比它低
//   background: rgba(244, 247, 250, 0.2); // 半透明淡蓝色
//   box-shadow: inset 0 0 100px rgba(30, 144, 255, 0.4); // 蓝色内发光
//   pointer-events: none; // 不阻挡点击
// }

.content {
  // display: flex;
  z-index: 99;
  position: relative;
  width: 860px;
  left: 0;
  right: 0;
  margin: 0 auto;
  transform: translateY(-50%);
  top: 50%;
  height: 400px;
  border-radius: 10px;
}

.login {
  flex: 1;
}

.loging-btn {
  margin-top: 10px;

  button {
    width: 100%;
    height: 44px;
    font-size: 16px;
    font-weight: 500;
    border: none;
    border-radius: 24px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(64, 158, 255, 0.2);
    background-image: linear-gradient(135deg, #409eff, #66b1ff);
    color: white;
    letter-spacing: 1px;

    &:hover {
      background-image: linear-gradient(135deg, #66b1ff, #409eff);
      box-shadow: 0 6px 16px rgba(64, 158, 255, 0.35);
      transform: translateY(-2px);
    }

    &:active {
      transform: scale(0.98);
      box-shadow: 0 3px 6px rgba(64, 158, 255, 0.25);
    }

    &:disabled {
      background-color: #c0c4cc !important;
      cursor: not-allowed;
      box-shadow: none;
    }
  }

  .btn-text {
    font-size: 16px;
    font-weight: 600;
    // letter-spacing: 1px;
  }
}


.content {
  display: flex;
  z-index: 99;
  position: relative;
  width: 860px;
  left: 0;
  right: 0;

  margin: 0 auto;
  transform: translateY(-50%);
  // background: #dedede40;
  top: 50%;
  height: 400px;
  border-radius: 10px;

  // .l-left {
  //   border-top-left-radius: 5px;
  //   border-bottom-left-radius: 5px;
  //   width: 400px;
  //   // background-image: linear-gradient(135deg, #0d82ff 10%, #0cd7bd);
  //   // border: 1px solid #5c87ff;
  // }
  .l-left {
    position: fixed;
    top: -300px;
    left: -700px;
    width: 100vw;
    height: 100vh;

    background: url(~@/assets/imgs/bg_inco.png) no-repeat center center;
    background-size: 10%;
    /* ✅ 放大整张图 */
    background-position: center;
    z-index: -1;

  }

  .brand-info {
    position: absolute;
    bottom: 300px; // 根据视觉需求调整位置
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    z-index: 2;

    .brand-name {
      font-size: 24px;
      color: #2a85ff;
      font-weight: bold;
      letter-spacing: 2px;
      animation: fadeInUp 1.5s ease forwards;
    }

    .brand-slogan {
      font-size: 16px;
      font-style: italic;
      font-family: 'Georgia', serif;
      color: #5fa8ff;
      margin-top: 6px;
      text-shadow: 1px 1px 2px rgba(0, 102, 255, 0.3);
      animation: fadeInUp 2s ease forwards;
    }
  }

  @keyframes fadeInUp {
    from {
      opacity: 0;
      transform: translateY(20px);
    }

    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

}

.desc {
  text-align: left;
  width: 450px;
  padding: 10px 30px;
  box-sizing: border-box;
  height: 100%;
}

.desc p {
  font-size: 15px;
  color: white;
  line-height: 30px;
}

.desc p:before {
  top: -1px;
  content: "o";
  position: relative;
  margin-right: 7px;
}

.title {
  z-index: 999;
  font-size: 70px;
  font-weight: bold;
  color: white;
}


// // 新增左右半圆形状样式
// .l-bg, .r-bg {
//   position: absolute;
//   border-radius: 50%;
//   opacity: 0.5;
//   filter: blur(120px);
//   animation: float 8s ease-in-out infinite;
//   z-index: 1;
// }

// .l-bg {
//   width: 600px;
//   height: 600px;
//   top: 20%;
//   left: -200px;
//   background: radial-gradient(circle at center, #00c6ff, #0072ff);
// }

// .r-bg {
//   width: 800px;
//   height: 800px;
//   bottom: 10%;
//   right: -300px;
//   background: radial-gradient(circle at center, #05f6c5, #1dd5ff);
// }

// @keyframes float {
//   0%, 100% {
//     transform: translateY(0px) scale(1);
//   }
//   50% {
//     transform: translateY(20px) scale(1.05);
//   }
// }</style>

<style lang="less" scoped>
// .form-user {
//   margin: 25px 0;

//   .item {
//     display: flex;
//     padding-bottom: 5px;
//     border-bottom: 1px solid #eee;
//     margin-bottom: 30px;
//     display: flex;

//     .f-text {
//       color: #484848;
//       font-weight: 400;
//       width: 110px;
//       font-size: 16px;
//       text-align: left;

//       i {
//         position: relative;
//         top: -1px;
//         right: 5px;
//       }
//     }


//     .f-input {
//       border: 0px;
//       flex: 1;
//     }


//     .code {
//       position: relative;
//       cursor: pointer;
//       top: -5px;
//       width: 74px;
//       border: 1px solid #fdfdfd;
//       border-radius: 2px;
//       height: 35px;
//       margin-left: 10px;
//     }
//   }
// }
.form-user {
  margin: 25px 0;

  .item {
    display: flex;
    align-items: center;
    background: #f8f8f8;
    border-radius: 10px;
    padding: 10px 14px;
    margin-bottom: 25px; // 输入框之间的垂直间距
    border: 1px solid #ddd;
    transition: all 0.3s ease;

    &:hover {
      border-color: #409eff;
      box-shadow: 0 0 4px rgba(64, 158, 255, 0.3);
    }

    .icon {
      color: #999;
      font-size: 18px;
      margin-right: 10px;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    input {
      flex: 1;
      border: none;
      outline: none;
      background: transparent;
      font-size: 16px;
      color: #333;

      &::placeholder {
        color: #bbb;
      }
    }
  }
}


input:-webkit-autofill {
  box-shadow: 0 0 0px 1000px white inset;
}

.login-contianer {
  position: absolute;
  top: 50%;
  left: 620px;
  transform: translate(-50%, -50%);
  z-index: 10;



  // 新增样式
  .login-form {
    position: relative;
    overflow: hidden;
    width: 400px;
    height: 460px;
    padding: 30px 40px;
    background: linear-gradient(145deg, #ffffff, #f2f2f2);
    border-radius: 20px; // 圆角优化
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15); // 更柔和的阴影
    transition: all 0.3s ease;

    h2 {
      font-weight: 500;
      padding: 10px 0px;
      text-align: left;
      margin-top: 15px;
    }

    .v-tag {
      top: -23px;
      text-align: center;
      position: absolute;
      right: -43px;
      line-height: 49px;
      top: -17px;
      padding-left: 21px;
      font-size: 12px;
      width: 158px;
      background: #3a8ee6;
      padding-top: 25px;
      color: white;
      -webkit-transform: rotate(40deg);
      letter-spacing: 2px;
    }

    // 新增样式
    &:hover {
      box-shadow: 0 20px 45px rgba(0, 0, 0, 0.2);
      transform: translateY(-2px);
    }
  }

  .login-title {
    font-size: 30px;
    color: #06a3ea;
  }
}

.loging-btn {
  margin-top: 20px;
}

.action {
  text-align: right;
  margin-top: 20px;
  font-size: 12px;
  color: #9c9c9c;
  cursor: pointer;

  a {
    margin-left: 20px;
  }
}

.login-footer {
  cursor: pointer;
  padding: 10px;
  text-align: center;
  font-size: 14px;
  position: absolute;
  width: 100%;
  bottom: 0px;
  background: #06a3ea;
  border-top: 1px solid #e2e2e2;

  i {
    position: relative;
    top: -2px;
    margin-right: 5px;
  }

  a {
    margin-left: 30px;
    color: #f9ebd0;
  }
}

@media screen and (max-width: 600px) {
  .desc {
    display: none;
  }

  .bg {
    background-image: none;
  }

  .login-form {
    box-shadow: none !important;
  }

  .login-form {
    width: 100% !important;
  }

  .login-footer,
  .r-bg,
  .l-bg {
    display: none;
  }

  .l-left {
    display: none;
  }

  .c-bg-item {
    background: none !important;
  }
}

.link a {
  text-decoration: none;

  color: #ffff;
  border: 1px solid #ffff;
  width: 80px;
  margin-right: 5px;
  display: inline-block;
  margin-bottom: 0;
  font-weight: 400;
  text-align: center;
  touch-action: manipulation;
  cursor: pointer;
  background-image: none;

  white-space: nowrap;
  user-select: none;
  padding: 5px 15px 6px;
  font-size: 12px;
  border-radius: 32px;
}
</style>
<style scoped>
input:-webkit-autofill {
  -webkit-box-shadow: 0 0 0px 1000px white inset !important;
}

input {
  background: white;
  display: block;
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 0;
  color: #323233;
  line-height: inherit;
  text-align: left;
  border: 0;
  outline: none;
  font-size: 16px;
  line-height: 20px;
}
</style>
<style lang="less" scoped>
.c-bg {
  position: absolute;
  width: 100%;
  height: 200px;

  .c-bg-item {
    width: 25%;
    background: #00a7f5;
    height: 200px;
  }
}

.app-link {
  text-align: center;
  padding-top: 21px;
  font-size: 14px;

  a {
    position: relative;
    cursor: pointer;
    width: 70px;
    color: #1483f6;
    margin: 20px 20px 0 0;
  }

  img {
    display: none;
  }

  a:hover {
    img {
      display: block;
      position: absolute;
      z-index: 999999999;
      top: -130px;
      width: 120px;
      left: -22px;
      border: 1px solid #b1b1b1;
    }
  }
}

// 启动之前添加 $env:NODE_OPTIONS="--openssl-legacy-provider"
// http://localhost:9991/index.html 
// https://imes.625sc.com/#/Ware_WareHouseBill
</style>
